home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Justifying with Glyphs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.6 KB  |  104 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. void JustifyGlyph(WindowPtr sampleWindow)
  36.     {
  37.     /* Variables */
  38.     char            *myString = "pow-wow";
  39.     gxLayoutOptions    gxLayoutOptions;
  40.     gxLine            myLine;
  41.     gxPoint            myPoint;
  42.     gxRunControls        gxRunControls;
  43.     gxShape            layout;
  44.     short            len, level = 0;
  45.     gxStyle            myStyle;
  46.     gxViewPort        aViewPort;
  47.     
  48.     /* Initialization */
  49.     
  50.     myPoint.x = ff(30);
  51.     myPoint.y = ff(50);
  52.     
  53.     aViewPort = GXNewWindowViewPort(sampleWindow);
  54.     SetDefaultViewPort(aViewPort);
  55.     
  56.     len = MyStrLen(myString);
  57.     InitializeRunControls(&gxRunControls);
  58.     
  59.     InitializeLayoutOptions(&gxLayoutOptions);
  60.     gxLayoutOptions.width = ff(500);
  61.     gxLayoutOptions.just = 0;
  62.     
  63.     myLine.first.x = myLine.last.x = myPoint.x;
  64.     myLine.first.y = 0;
  65.     myLine.last.y = ff(1000);
  66.     GXDrawLine(&myLine);
  67.     
  68.     myLine.first.x = myLine.last.x = myPoint.x + gxLayoutOptions.width;
  69.     GXDrawLine(&myLine);
  70.     
  71.     myStyle = NewLayoutStyle((char *) "\pWackyTimes2 Roman", ff(50), 0, nil, nil, 0, nil);
  72.     
  73.     layout = GXNewLayout(
  74.         1, &len, (void *) &myString,
  75.         1, &len, &myStyle,
  76.         1, &len, &level,
  77.         &gxLayoutOptions, &myPoint);
  78.     GXDrawShape(layout);
  79.     
  80.     gxLayoutOptions.just = fract1 / 4;
  81.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  82.     GXMoveShape(layout, 0, ff(75));
  83.     GXDrawShape(layout);
  84.     
  85.     gxLayoutOptions.just = fract1 / 2;
  86.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  87.     GXMoveShape(layout, 0, ff(75));
  88.     GXDrawShape(layout);
  89.     
  90.     gxLayoutOptions.just = 3 * (fract1 / 4);
  91.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  92.     GXMoveShape(layout, 0, ff(75));
  93.     GXDrawShape(layout);
  94.     
  95.     gxLayoutOptions.just = fract1;
  96.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  97.     GXMoveShape(layout, 0, ff(75));
  98.     GXDrawShape(layout);
  99.     
  100.     GXDisposeShape(layout);
  101.     GXDisposeStyle(myStyle);
  102.     GXDisposeViewPort(aViewPort);
  103.     }    /* main */
  104.